package singleton;

public class SingleObject {

    // 饿汉式单例模式
//    private static SingleObject instance = new SingleObject();


    // 懒汉式单例模式
    private static SingleObject instance;

    private SingleObject() {}

    public static synchronized  SingleObject getInstance() {

        if (instance == null) {
            instance = new SingleObject();
        }
        return instance;
    }

    public void showMessage() {
        System.out.println("Hello World!");
    }




}
